package org.stvd.entities.common;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;
import org.stvd.core.annotation.serializer.DateTimeSerializer;
import org.stvd.core.util.StringUtil;
import org.stvd.entities.base.BaseEntity;
import org.stvd.entities.common.LongJsonDeserializer;
import org.stvd.entities.common.LongJsonSerializer;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 附件映射-实体类
 * @author houzx
 */
@Entity
@Table(name ="affix_info")
public class AffixInfo extends BaseEntity{

    private static final long serialVersionUID = -8561865985819730990L;
    
    @Id
    @Column(name = "id", nullable = false)
    @JsonDeserialize(using = LongJsonDeserializer.class)
    @JsonSerialize(using = LongJsonSerializer.class)
    private Long id= null;
    
    /**
     * 附件ID
     */
    @Column(name = "affix_id", nullable = false)
    @JsonDeserialize(using = LongJsonDeserializer.class)
    @JsonSerialize(using = LongJsonSerializer.class)
    private Long affixId = null;
    
    /**
     * 附件名称
     */
    @Column(name = "affix_name")
    private String affixName = "";
    
    /**
     * 附件本地地址
     */
    @Column(name = "affix_local_url")
    private String affixLocalUrl = "";
    
    /**
     * 附件远程地址
     */
    @Column(name = "affix_remote_url")
    private String affixRemoteUrl = "";
    
    /**
     * 附件大小
     */
    @Column(name = "affix_size")
    private Integer affixSize = null;
    
    /**
     * 附件扩展类型
     */
    @Column(name = "affix_extension")
    private String affixExtension = "";
    
    /**
     * 主体类型
     */
    @Column(name = "info_type", nullable = false)
    private String infoType= "";
    
    /**
     * 主体数据表
     */
    @Column(name = "info_table", nullable = false)
    private String infoTable= "";
    
    /**
     * 主体数据ID
     */
    @Column(name = "info_id", nullable = false)
    private String infoId= "";
    
    /**
     * 附件校验状态{-1：已删除；0：未校验；1：已校验；}
     */
    @Column(name = "check_status", nullable = false)
    private String checkStatus = "";
    
    /**
     * 校验时间
     */
    @Column(name = "check_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using=DateTimeSerializer.class)
    private Date checkTime = null;

    public Long getId() {
    	return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public Long getAffixId() {
        return affixId;
    }
    
    public void setAffixId(Long affixId) {
        this.affixId = affixId;
    }
    
    public String getAffixName() {
        return affixName;
    }
    
    public void setAffixName(String affixName) {
        this.affixName = affixName;
    }
    
    public String getAffixLocalUrl() {
        return affixLocalUrl;
    }
    
    public void setAffixLocalUrl(String affixLocalUrl) {
        this.affixLocalUrl = affixLocalUrl;
    }
    
    public String getAffixRemoteUrl() {
        return affixRemoteUrl;
    }
    
    public void setAffixRemoteUrl(String affixRemoteUrl) {
        this.affixRemoteUrl = affixRemoteUrl;
    }
    
    public Integer getAffixSize() {
        return affixSize;
    }
    
    public void setAffixSize(Integer affixSize) {
        this.affixSize = affixSize;
    }
    
    public String getAffixExtension() {
        return affixExtension;
    }
    
    public void setAffixExtension(String affixExtension) {
        this.affixExtension = affixExtension;
    }
    
    public String getInfoType() {
        return infoType;
    }
    
    public void setInfoType(String infoType) {
        this.infoType = infoType;
    }
    
    public String getInfoTable() {
        return infoTable;
    }
    
    public void setInfoTable(String infoTable) {
        this.infoTable = infoTable;
    }
    
    public String getInfoId() {
        return infoId;
    }
    
    public void setInfoId(String infoId) {
        this.infoId = infoId;
    }
    
    public String getCheckStatus() {
        if(StringUtil.isEmpty(this.checkStatus)) {
            this.checkStatus = "0";
        }
        return checkStatus;
    }
    
    public void setCheckStatus(String checkStatus) {
        this.checkStatus = checkStatus;
    }
    
    public Date getCheckTime() {
        return checkTime;
    }
    
    public void setCheckTime(Date checkTime) {
        this.checkTime = checkTime;
    }
}
